package com.copa.l121;

/**
 * @author copa
 * @createDate 2022-07-28 10:19
 * @function 暴力法（但是不要用！！！因为超出时间限制）
 */
public class Test1 {

    public int maxProfit(int[] prices) {
        int result = 0;
        if (prices.length <= 1) {
            return result;
        }
        for (int i = 0; i < prices.length - 1; i++) {
            for (int j = i + 1; j < prices.length; j++) {
                result = Math.max(result, prices[j] - prices[i]);
            }
        }
        return result;
    }

    public static void main(String[] args) {
        //int[] prices = {7,1,5,3,6,4};
        int[] prices = {7,6,4,3,1};
        System.out.println(new Test1().maxProfit(prices));
    }
}
